package com.baosu.controller.front;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baosu.domain.Category;
import com.baosu.domain.Result;
import com.baosu.service.CategoryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/front/category")
@Api(tags = "分类接口-前台")
public class CategoryFrontController {

    @Autowired
    private CategoryService categoryService;

    @GetMapping("/list")
    @ApiOperation(value = "获取所有的分类")
    public Result<List<Category>> list(){
        List<Category> categorys = categoryService.list();
        return Result.ok(categorys);
    }

    @GetMapping("/articleList")
    @ApiOperation(value = "根据分类ID查询文章列表")
    public Result getArticlelistByCategoryId(int pagenum, int pagesize, Long id){
        return categoryService.getArticlelistByCategoryId(pagenum,pagesize,id);
    }


}
